from time import sleep

from selenium.webdriver.common.by import By

from base.element_base import ElementBase


class LoginPage(ElementBase):

    def __init__(self):
        super().__init__()

        self.ele_username = (By.CSS_SELECTOR, '#username')
        self.ele_pwd = (By.CSS_SELECTOR, '#password')
        self.ele_verify = (By.CSS_SELECTOR, '#verify_code')
        self.ele_login = (By.LINK_TEXT, '登    录')

    def login_func(self, name, pwd, verify):
        self.input_element(self.posit_element(self.ele_username), name)

        self.input_element(self.posit_element(self.ele_pwd), pwd)

        self.input_element(self.posit_element(self.ele_verify), verify)

        sleep(1)
        self.click_element(self.posit_element(self.ele_login))
